#!/usr/bin/perl -w
use strict;
use autodie;

$#ARGV < 2 and die (`basename "$0 in.vcf ID Description"`);

my ($id, $desp)=(@ARGV[1..2]); # @ not $


open my $vcf, $ARGV[0] or die "Can not open file.\n";

$" = "\t";  # change default filed separator

while (<$vcf>) {

	if (/^##/) {

		if (/^##FILTER=<ID=${id},/) {
			die "Error: filter id exists. no nothing.\n";
		}else {
			print;
		}
		
	}elsif (/^#/) {
		print "##FILTER=<ID=${id},Description=\"${desp}\">\n";
		print;
		
	}else {
		#CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO    FORMAT
		my @Fs = split "\t";
		if ($Fs[6]) {
			if ($Fs[6] eq "." || $Fs[6] eq "PASS") {
				$Fs[6] = $id;
			}else {
				$Fs[6].=";$id";
			}

		}else {
			$Fs[6] = $id;
		}
		
		print "@Fs";
	}
	
}

close $vcf;